package wap;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import wap.queue.IQueue;
import wap.queue.impl.QueueWapImpl;

/**
 * @描述：一个线程去往队列中添加gz文件，另外3个线程处理文件
 * @作者：hongxingfan
 * @时间：2014年9月19日 上午9:40:44
 */
public class Main {

	public static void main(String[] args) throws InterruptedException, ExecutionException {

		IQueue<String> queue = new QueueWapImpl<String>();

		ExecutorService pool = Executors.newFixedThreadPool(6);

		ThreadProduct product = new ThreadProduct("D:/sohuwl-car.log.2014-09-21");
		product.setQueue(queue);

		Future<String> product1 = pool.submit(product);

		ThreadConsum consum1 = new ThreadConsum();
		consum1.setQueue(queue);
		ThreadConsum consum2 = new ThreadConsum();
		consum2.setQueue(queue);
		ThreadConsum consum3 = new ThreadConsum();
		consum3.setQueue(queue);

		Future<String> future2 = pool.submit(consum1);
		Future<String> future3 = pool.submit(consum2);
		Future<String> future4 = pool.submit(consum3);

		pool.shutdown();
	}
}
